package game.action.actions.login;

import game.action.BaseAction;
import game.system.UserModel;
import game.system.UserVo;
import game.utils.UuidUtils;

public class UserLoginAction extends BaseAction {
	private static final String TOKEN = "@1#2$34%ds^we2&32*";//加密令牌
	public static final String USER_LOGIN = "userLoginAction?message=login_success";
	
	private String uid;
	private String name;
	
	public UserLoginAction(){
		this.setValidataLogin(false);
	}
	
	@Override
	public void execute() {
		UserVo userVo = new UserVo();
		userVo.setGameThread(this.getGameThread());
		userVo.setId(this.getGameThread().getUuid());
		userVo.setName(name);
		userVo.setIp(this.getGameThread().getSocket().getInetAddress().getHostAddress().toString());
		this.getGameThread().setUser(userVo);
		UserModel.addUser(userVo);
		
		userVo.send(USER_LOGIN);
	}

	
	@Override
	public boolean validate() {
		return true;
	}

	@Override
	public String initParams() {
		this.name = params.get("name").toString();
		return null;
	}

}
